package chapter7.TreeSet;

import java.util.*;
public class Example {
    public static void main(String[] args) {
        Person person1 = new Person("马先生", 181);
        Person person2 = new Person("李先生", 186);
        Person person3 = new Person("王小姐", 193);
        Person person4 = new Person("尹先生", 196);
        Person person5 = new Person("王先生", 175);
        TreeSet<Person> treeSet = new TreeSet<Person>();
        treeSet.add(person1);
        treeSet.add(person2);
        treeSet.add(person3);
        treeSet.add(person4);
        treeSet.add(person5);
        System.out.println("初始化的集合：");
        Iterator<Person> it = treeSet.iterator();
        while (it.hasNext()) {
            Person person = it.next();
            System.out.println(person.getId_card() + " "+ person.getName());
        }
    }
}